package com.hangsu.train.components.web.job;

import cn.hutool.extra.spring.SpringUtil;
import com.hangsu.train.components.entity.User;
import com.hangsu.train.components.params.PageRequestParam;
import com.hangsu.train.components.service.UserService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.data.domain.Page;

import java.util.Date;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Slf4j
public class ReportJob implements Job {

    private static final Lock lock = new ReentrantLock();

    private final UserService userService= SpringUtil.getBean(UserService.class);

    @Override
    public void execute (JobExecutionContext context) throws JobExecutionException {
        Map<String, Object> jobDataMap = context.getMergedJobDataMap();
        if (lock.tryLock()) {
            try {
                log.info("start execute job");
                PageRequestParam requestParam = new PageRequestParam();

            }catch (Exception e){
                e.printStackTrace();
            }
            finally {
                lock.unlock();
            }
        } else {
            log.warn("current thread is locked job is cancel");
        }
    }
}